package org.test.string.work;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.test.junit.SimpleTest;

public class GenString extends SimpleTest{
	

	@Test
	public void cutString() throws IOException{
		File file = new File("./src/org/test/string/work/cutString.txt");
//		System.out.println(file.getAbsolutePath());
		FileReader fr = new FileReader(file);
		BufferedReader bfr = new BufferedReader(fr);
		
		StringBuffer sb = new StringBuffer();
		for (String str = bfr.readLine(); str != null; str = bfr.readLine()) {
			//String merchantId = request.getParameter("merchantId");
//			if(!StringUtils.contains(str, "T_EZF_FLOW")){
//				continue;
//			}
			str = pickUpMsg(str);
			log.info("提取后:"+str);
			str = detail(str);
			sb.append(str);
			sb.append("\n");
		}
		log.info(sb);
	}
	
	
	/**生成的信息**/
	private String detail(String str){
//		str  = "signData+=(String)paramMap.get(\""+str+"\");";
//		str  ="theparam.put(\""+str+"\","+str+");";
//		str = "theparam.put(\""+str+"\",UppCore.putMapNotNull("+str+"));";
//		str = "String "+str+" =  util.getValue(res, \""+str+"\");";
//		str = "responseMap.put(\""+str+"\", util.getValue(res, \""+str+"\"));";
		
		/*
		String interfaceStr = str.substring(0,str.indexOf("="));
		String trancodeStr = str.substring(str.indexOf(",")+1);
		String target = "transInterfaceMap.put(\""+trancodeStr+"\", \""+interfaceStr+"\");";
		*/
//		str = "String "+str+" = DStringUtil.getStringNotNullFromReqParam(dmap, \""+str+"\");";
		
		String bizcode = str.substring(0,7);
		String desc = str.substring(7);
		String s = "insert into TD_S_BIZLIST (BIZ_CODE, BIZ_NAME, RECK_TAG, SECURITY_TAG) values ('"+bizcode+"', '"+desc+"', '', '');";
		return s;
	}
	
	
	 /**提取信息**/
	 private String pickUpMsg(String lineStr){
		 return lineStr;
//		 String beginStr = "(\"";
//		 String endStr = "\")";
//		 int begin = lineStr.indexOf(beginStr)+beginStr.length();
//		 int end = lineStr.indexOf(endStr);
//		 String targetStr = lineStr.substring(begin, end);
//		 
//		 return targetStr;
	 }
}
